﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace OrBitDataModule.Common
{
    public static class ConfigHelper
    {
        static string configPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App.config");
        static ExeConfigurationFileMap map;
        static Configuration Config;

        static ConfigHelper()
        {
            map = new ExeConfigurationFileMap
            {
                ExeConfigFilename = configPath
            };
            Config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);
        }
        public static string GetValue(string key) => Config.AppSettings.Settings[key].Value;
        public static void SetValue(string key, string value)
        {
            Config.AppSettings.Settings[key].Value = value;
            Config.Save();
        }
    }
}
